﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;
using Autodesk.Revit.Exceptions;
using Autodesk.Revit.UI;
using YJKRevitWndr.InsertDoorAndWindow.Cmd;
using YJKRevitWndr.InsertDoorAndWindow.Forms;
using YArchitech.Controls;
using YArchitech.Revit;
using YJKArchUtils.ColumnProfileAnalyze;
using YJKRevitFamilyDataBase;
using YJKGeometryFuncs;

namespace YJKRevitWndr.InsertDoorAndWindow.InsertOperation
{
	internal class InsertDoorAndWindowManage
	{
		[DllImport("user32.dll", EntryPoint = "SendMessageA")]
		public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);

		[DllImport("user32.dll")]
		public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

		public InsertDoorAndWindowManage(ExternalCommandData cmdData, BuiltInCategory bc)
		{
			this.m_cmdData = cmdData;
			this.m_uiApp = cmdData.Application;
			this.m_uiDoc = this.m_uiApp.ActiveUIDocument;
			this.m_doc = this.m_uiDoc.Document;
			this.m_App = this.m_uiApp.Application;
			this.m_category = bc;
			InsertDoorAndWindowManage.m_dis = new Dis(this.Disp);
		}

		public bool InsertMain(string m_strFamilyName, string m_strFamilyType)
		{
			this.m_App.DocumentChanged += this.M_App_DocumentChanged;
			InsertDoorAndWinForm insertDoorAndWinForm = new InsertDoorAndWinForm(this.m_cmdData, this.m_category, m_strFamilyName, m_strFamilyType);
			try
			{
				insertDoorAndWinForm.Show(CmdInsertDoor._hWndRevit);
				this.m_jig = new XInputDialog(this.m_uiDoc, insertDoorAndWinForm);
				do
				{
					RefreshImage2D delRefreshImage2D = insertDoorAndWinForm.DelRefreshImage2D;
					if (delRefreshImage2D != null)
					{
						delRefreshImage2D(insertDoorAndWinForm.m_tnSelect);
					}
					insertDoorAndWinForm.DelRefreshImage2D = null;
					if (insertDoorAndWinForm.DelLoadFamily != null)
					{
						this.m_family = insertDoorAndWinForm.DelLoadFamily();
						this.m_doorData.Symbol = this.m_family.GetSymbols().FirstOrDefault<FamilySymbol>();
						insertDoorAndWinForm.m_symbol = this.m_family.GetSymbols().FirstOrDefault<FamilySymbol>();
						insertDoorAndWinForm.SetControlData();
						insertDoorAndWinForm.GetDoorData();
					}
					insertDoorAndWinForm.DelLoadFamily = null;
					this.m_doorData = insertDoorAndWinForm.m_doorData;
					this.m_family = this.m_doorData.Symbol.Family;
					if (this.m_delModifyInstance != null)
					{
						this.m_bIsLock = false;
						this.m_delModifyInstance();
						this.m_bIsLock = true;
					}
					this.m_delModifyInstance = null;
					this.m_elem = null;
					string a = string.Empty;
					Parameter parameter = this.m_doorData.Symbol.get_Parameter(BuiltInParameter.CASEWORK_WIDTH);
					if (parameter != null)
					{
						a = parameter.AsValueString();
					}
					string a2 = string.Empty;
					Parameter parameter2 = this.m_doorData.Symbol.get_Parameter(BuiltInParameter.FAMILY_HEIGHT_PARAM);
					if (!parameter2.IsReadOnly)
					{
						a2 = parameter2.AsValueString();
					}
					string text = string.Empty;
					Parameter parameter3 = this.m_doorData.Symbol.GetParameter("防火等级");
					if (parameter3 != null)
					{
						text = parameter3.AsString();
						if (text == null)
						{
							text = "";
						}
					}
					if (a != this.m_doorData.DoorAndWinWidth || a2 != this.m_doorData.DoorAndWinHigh || text != this.m_doorData.FireProtectionGrade)
					{
						this.m_doorData.Symbol = this.ChangeType(insertDoorAndWinForm, this.m_doorData.Symbol);
					}
					this.m_insertMode = insertDoorAndWinForm.m_insertMode;
					this.Preprocessing(insertDoorAndWinForm);
				}
				while (this.operaType != OperationType.Exit);
				insertDoorAndWinForm.Close();
				this.m_App.DocumentChanged -= this.M_App_DocumentChanged;
				this.m_jig.Dispose();
			}
			catch (Exception)
			{
				this.m_jig.Dispose();
				insertDoorAndWinForm.Close();
				return false;
			}
			return true;
		}

		private Result Preprocessing(InsertDoorAndWinForm inserDoorAndWinForm)
		{
			string strPrompt = string.Empty;
			string strPrompt2 = string.Empty;
			if ((int)this.m_category == -2000023)
			{
				strPrompt = "输入数值超出范围，请重新输入插入门个数";
				strPrompt2 = "输入插入门个数";
			}
			else
			{
				strPrompt = "输入数值超出范围，请重新输入插入窗个数";
				strPrompt2 = "输入插入窗个数";
			}
			if (this.operaType != OperationType.Refresh)
			{
				if (this.m_insertMode == InsertMode.eByButtress)
				{
					this.m_jig.SetPromptStateNew("垛宽", true, "", true);
					if (this.m_strPlieWidth != "" && this.m_strPlieWidth != null)
					{
						this.m_jig.inputForm.SetInputValue(this.m_strPlieWidth);
					}
				}
				else if (this.m_insertMode == InsertMode.eByEqualWall)
				{
					if (this.m_bIsAgain)
					{
						this.m_jig.SetPromptStateNew(strPrompt, true, "", true);
						this.m_strEqualWall = "";
					}
					else
					{
						this.m_jig.SetPromptStateNew(strPrompt2, true, "", true);
					}
					if (this.m_strEqualWall != "" && this.m_strEqualWall != null)
					{
						this.m_jig.inputForm.SetInputValue(this.m_strEqualWall);
					}
				}
				else if (this.m_insertMode == InsertMode.eByPickPoint)
				{
					this.m_jig.SetPromptStateNew("", false, "", false);
				}
			}
			this.m_lstInstanceOlds = AssistFunc.GetAllFamilyInstance(this.m_doc, this.m_category).ToList<ElementId>();
			inserDoorAndWinForm.OperaType = OperationType.Init;
			if (!this.PromptForFamilyInstancePlacement(inserDoorAndWinForm))
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			this.operaType = inserDoorAndWinForm.OperaType;
			inserDoorAndWinForm.OperaType = OperationType.Init;
			if (this.operaType == OperationType.SwitchOperationMode || this.operaType == OperationType.Refresh || this.operaType == OperationType.LoadFamily)
			{
				return Autodesk.Revit.UI.Result.Succeeded;
			}
			if (this.m_elem == null)
			{
				this.operaType = OperationType.Exit;
			}
			this.m_bIsAddTag = inserDoorAndWinForm.AddTag;
			this.OperationMode();
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		private void M_App_DocumentChanged(object sender, DocumentChangedEventArgs e)
		{
			if (!this.m_bIsLock)
			{
				return;
			}
			List<ElementId> list = AssistFunc.SubCollection(AssistFunc.GetAllFamilyInstance(this.m_doc, this.m_category).ToList<ElementId>(), this.m_lstInstanceOlds).ToList<ElementId>();
			if (list.Count != 0)
			{
				this.m_elem = RevitVersionFuncs.GetElement(this.m_doc, list[0]);
				this.SendESC();
				this.SendESC();
			}
		}

		private void OperationMode()
		{
			switch (this.m_insertMode)
			{
			case InsertMode.eByPickPoint:
				this.PickPtInsert();
				return;
			case InsertMode.eByButtress:
				this.PlieWidthInsert();
				return;
			case InsertMode.eByEqualWall:
				this.EqualWallInsert();
				return;
			default:
				return;
			}
		}

		private void Disp()
		{
			int wMsg = 7;
			if ((int)this.m_category == -2000023)
			{
				InsertDoorAndWindowManage.SendMessage(CmdInsertDoor._hWndRevit.Handle, wMsg, IntPtr.Zero, IntPtr.Zero);
				return;
			}
			InsertDoorAndWindowManage.SendMessage(CmdInsertWin._hWndRevit.Handle, wMsg, IntPtr.Zero, IntPtr.Zero);
		}

		private void SendESC()
		{
			int wMsg = 7;
			if ((int)this.m_category == -2000023)
			{
				InsertDoorAndWindowManage.SendMessage(CmdInsertDoor._hWndRevit.Handle, wMsg, IntPtr.Zero, IntPtr.Zero);
			}
			else
			{
				InsertDoorAndWindowManage.SendMessage(CmdInsertWin._hWndRevit.Handle, wMsg, IntPtr.Zero, IntPtr.Zero);
			}
			int bVk = 27;
			int dwFlags = 0;
			int dwFlags2 = 2;
			InsertDoorAndWindowManage.keybd_event((byte)bVk, 0, dwFlags, 0);
			InsertDoorAndWindowManage.keybd_event((byte)bVk, 0, dwFlags2, 0);
		}

		private FamilySymbol ChangeType(InsertDoorAndWinForm inserDoorAndWinForm, FamilySymbol symbol)
		{
			FamilySymbol familySymbol = null;
			string name = symbol.Name;
			string text = string.Empty;
			foreach (char c in name)
			{
				if (c > '@' && c < '[')
				{
					text += c.ToString();
				}
			}
			if (text != "" && text != null)
			{
				Transaction transaction = new Transaction(this.m_doc, "ModifySymbol");
				int num = (int)Math.Round(double.Parse(this.m_doorData.DoorAndWinWidth) / 100.0, MidpointRounding.AwayFromZero);
				int num2 = (int)Math.Round((double)int.Parse(this.m_doorData.DoorAndWinHigh) / 100.0, MidpointRounding.AwayFromZero);
				string text3 = num.ToString();
				if (text3.Length == 1)
				{
					text3 = "0" + text3;
				}
				string text4 = num2.ToString();
				if (text4.Length == 1)
				{
					text4 = "0" + text4;
				}
				string text5 = string.Empty;
				if (this.m_doorData.FireProtectionGrade != "" && this.m_doorData.FireProtectionGrade != null && this.m_doorData.FireProtectionGrade != "无")
				{
					string text6 = this.m_doorData.FireProtectionGrade.Substring(0, 1);
					text5 = string.Concat(new string[]
					{
						text,
						text3,
						text4,
						" ",
						text6
					});
				}
				else
				{
					text5 = text + text3 + text4;
				}
				Parameter parameter = symbol.GetParameter("门扇设计压力值");
				if (parameter != null)
				{
					string text7 = parameter.AsValueString();
					text7 = text7.Substring(0, 2);
					text5 = text5 + "-" + text7;
				}
				if (!this.IsExistence(text5, out familySymbol))
				{
					transaction.Start();
					familySymbol = (symbol.Duplicate(text5) as FamilySymbol);
					InsertDoorAndWindowManage.g_NewSymbolId = familySymbol.Id;
					this.SetParameter(familySymbol);
					transaction.Commit();
					if (familySymbol.IsValidObject)
					{
						inserDoorAndWinForm.RefshForm(familySymbol.Family.Name, text5);
						if (inserDoorAndWinForm.Tab == 1)
						{
							inserDoorAndWinForm.SelectNewNode();
						}
						inserDoorAndWinForm.m_symbol = familySymbol;
					}
					else
					{
						familySymbol = this.m_doorData.Symbol;
						inserDoorAndWinForm.SetControlData();
						inserDoorAndWinForm.GetDoorData();
					}
				}
				else
				{
					transaction.Start();
					this.SetParameter(familySymbol);
					transaction.Commit();
					inserDoorAndWinForm.m_symbol = familySymbol;
				}
				if (inserDoorAndWinForm.Tab == 0)
				{
					inserDoorAndWinForm.m_SelectSymbolLib = familySymbol;
				}
				return familySymbol;
			}
			return symbol;
		}

		private bool IsExistence(string strFamilyName, out FamilySymbol symbol)
		{
			FilteredElementCollector filteredElementCollector = new FilteredElementCollector(this.m_doc);
			filteredElementCollector.OfClass(typeof(FamilySymbol));
			if (filteredElementCollector != null)
			{
				foreach (Element element in filteredElementCollector.ToElements())
				{
					FamilySymbol familySymbol = element as FamilySymbol;
					if (((FamilySymbol)element).Name == strFamilyName && familySymbol.Family.Name == this.m_family.Name)
					{
						symbol = (FamilySymbol)element;
						return true;
					}
				}
			}
			symbol = null;
			return false;
		}

		private void PickPtInsert()
		{
			this.m_delModifyInstance = new InsertDoorAndWindowManage.DelModifyInstance(this.ModifyParameterAndAddTag);
		}

		private void ModifyParameterAndAddTag()
		{
			Transaction transaction = new Transaction(this.m_doc, "StartModifyInstance");
			try
			{
				transaction.Start();
				this.SetParameter(this.m_elem);
				FamilyInstance familyInstance = this.m_elem as FamilyInstance;
				FilteredElementCollector filteredElementCollector = new FilteredElementCollector(this.m_doc);
				ElementIntersectsElementFilter elementIntersectsElementFilter = new ElementIntersectsElementFilter(this.m_elem, false);
				filteredElementCollector.WherePasses(elementIntersectsElementFilter);
				filteredElementCollector.Excluding(new List<ElementId>
				{
					this.m_elem.Id
				});
				try
				{
					foreach (Element element in filteredElementCollector)
					{
						if (!(element.Id == familyInstance.Host.Id))
						{
							if (element is Wall)
							{
								Curve curve = (familyInstance.Host.Location as LocationCurve).Curve;
								Curve curve2 = (element.Location as LocationCurve).Curve;
								if (new YJKCurve(curve).IntersectionAllPoint(curve2).Count == 0)
								{
									continue;
								}
							}
							if (element.Category.Id.IntegerValue == -2000100 || element.Category.Id.IntegerValue == -2000023 || element.Category.Id.IntegerValue == -2000014 || element.Category.Id.IntegerValue == -2000011)
							{
								this.m_doc.DeleteElement(this.m_elem);
								this.m_doc.Regenerate();
								YJKMessageBox.Show("与已有对象重叠,无法布置！", MessageBoxButtons.OK);
								break;
							}
						}
					}
				}
				catch (Exception)
				{
				}
				transaction.Commit();
				if (this.m_bIsAddTag && this.GetTagSymbolNew())
				{
					this.DoInsertTag(this.m_elem as FamilyInstance);
				}
			}
			catch (Exception ex)
			{
				System.Windows.MessageBox.Show(ex.Message);
			}
		}

		private void SetParameter(Element elem)
		{
			elem.get_Parameter(BuiltInParameter.INSTANCE_SILL_HEIGHT_PARAM).Set(AssistFunc.mmToFeet(Convert.ToDouble(this.m_doorData.DoorAndWinBottomHigh)));
			Parameter parameter = elem.GetParameter("防火等级");
			if (parameter != null)
			{
				parameter.Set(this.m_doorData.FireProtectionGrade);
			}
		}

		private void SetParameter(FamilySymbol newSymbol)
		{
			newSymbol.get_Parameter(BuiltInParameter.CASEWORK_WIDTH).Set(AssistFunc.mmToFeet(Convert.ToDouble(this.m_doorData.DoorAndWinWidth)));
			Parameter parameter = newSymbol.get_Parameter(BuiltInParameter.FAMILY_HEIGHT_PARAM);
			if (!parameter.IsReadOnly)
			{
				parameter.Set(AssistFunc.mmToFeet(Convert.ToDouble(this.m_doorData.DoorAndWinHigh)));
			}
			Parameter parameter2 = newSymbol.GetParameter("防火等级");
			if (parameter2 != null)
			{
				parameter2.Set(this.m_doorData.FireProtectionGrade);
			}
		}

		private void DoInsertTag(FamilyInstance familyInstance)
		{
			try
			{
				if (familyInstance != null)
				{
					if (familyInstance.Category.Id.IntegerValue == -2000023)
					{
						ImpDoorWinTagInsert.Do(this.m_uiDoc, familyInstance, this.m_TagSymbol.Id);
					}
					else if (familyInstance.Category.Id.IntegerValue == -2000014)
					{
						ImpDoorWinTagInsert.Do(this.m_uiDoc, familyInstance, this.m_TagSymbol.Id);
					}
				}
			}
			catch
			{
			}
		}

		private bool PromptForFamilyInstancePlacement(InsertDoorAndWinForm inserDoorAndWinForm)
		{
			bool result;
			try
			{
				this.m_uiDoc.PromptForFamilyInstancePlacement(this.m_doorData.Symbol);
				result = true;
			}
			catch (Autodesk.Revit.Exceptions.OperationCanceledException)
			{
				result = true;
			}
			catch (Exception)
			{
				YJKMessageBox.Show("无法使用该族类型创建实例");
				inserDoorAndWinForm.SelectLastNode();
				result = false;
			}
			return result;
		}

		private void PlieWidthInsert()
		{
			this.m_delModifyInstance = new InsertDoorAndWindowManage.DelModifyInstance(this.RedrawInstancePlieWidth);
		}

		private void RedrawInstancePlieWidth()
		{
			Wall wall = null;
			XYZ zero = XYZ.Zero;
			XYZ zero2 = XYZ.Zero;
			XYZ zero3 = XYZ.Zero;
			FamilyInstance instance = this.m_elem as FamilyInstance;
			this.GetFamilyInstenceData(instance, ref wall, ref zero, ref zero2, ref zero3);
			double height = double.Parse(this.m_doorData.DoorAndWinBottomHigh);
			Transaction transaction = new Transaction(this.m_doc, "DelInstance");
			try
			{
				transaction.Start();
				this.m_doc.Delete(this.m_elem.Id);
				transaction.Commit();
			}
			catch (Exception)
			{
				if (transaction.IsValidObject && transaction.HasStarted())
				{
					transaction.RollBack();
				}
				return;
			}
			Transaction transaction2 = new Transaction(this.m_doc, "StartModifyInstance");
			try
			{
				this.m_strPlieWidth = this.m_jig.inputForm.GetInputValue();
				if (this.m_strPlieWidth == "" || this.m_strPlieWidth == null || this.m_strPlieWidth == "0")
				{
					YJKMessageBox.Show("请输入垛宽值");
				}
				else
				{
					double dButtWidth = double.Parse(this.m_strPlieWidth);
					transaction2.Start();
					XYZ zero4 = XYZ.Zero;
					Element element = this.DoInsert(dButtWidth, this.m_doorData.Symbol, wall, zero3, height, this.m_category, ref zero4);
					if (element == null)
					{
						transaction2.RollBack();
					}
					else
					{
						this.SetParameter(element);
						InsertDoorAndWindowManage.g_OverlapElemId = element.Id;
						transaction2.Commit();
						InsertDoorAndWindowManage.g_OverlapElemId = ElementId.InvalidElementId;
						Curve curve = (wall.Location as LocationCurve).Curve;
						if (element.IsValidObject)
						{
							Transaction transaction3 = new Transaction(this.m_doc, "ChangeOrientation");
							transaction3.Start();
							FamilyInstance familyInstance = element as FamilyInstance;
							familyInstance.flipFacing();
							familyInstance.flipFacing();
							if (familyInstance.CanFlipFacing)
							{
								if (curve is Arc)
								{
									Arc arc = curve as Arc;
									XYZ pt = (arc.Center - zero3).Normalize();
									XYZ pt2 = (arc.Center - zero4).Normalize();
									if (!this.IsFlip(pt, zero, pt2, familyInstance.FacingOrientation))
									{
										familyInstance.flipFacing();
									}
								}
								else if (!Geometry.IsEqual(zero, familyInstance.FacingOrientation))
								{
									familyInstance.flipFacing();
								}
							}
							if (familyInstance.CanFlipHand && !Geometry.IsEqual(zero2, familyInstance.HandOrientation))
							{
								familyInstance.flipHand();
							}
							transaction3.Commit();
							if (this.m_bIsAddTag && this.GetTagSymbolNew())
							{
								this.DoInsertTag(element as FamilyInstance);
							}
						}
					}
				}
			}
			catch (Exception)
			{
				if (transaction2.IsValidObject && transaction2.HasStarted())
				{
					transaction2.RollBack();
				}
			}
		}

		private void GetFamilyInstenceData(FamilyInstance instance, ref Wall wall, ref XYZ ptFace, ref XYZ ptHand, ref XYZ ptInsert)
		{
			wall = (instance.Host as Wall);
			ptFace = instance.FacingOrientation;
			ptHand = instance.HandOrientation;
			LocationPoint locationPoint = instance.Location as LocationPoint;
			ptInsert = locationPoint.Point;
		}

		private Element DoInsert(double dButtWidth, FamilySymbol doorType, Wall host, XYZ ptPick, double height, BuiltInCategory cate, ref XYZ ptNew)
		{
			double num = AssistFunc.feetToMM(doorType.get_Parameter(BuiltInParameter.CASEWORK_WIDTH).AsDouble());
			XYZ xyz = null;
			XYZ startPt = WallAssistFunc.GetStartPt(host);
			XYZ endPt = WallAssistFunc.GetEndPt(host);
			List<XYZ> list = new List<XYZ>();
			Curve curve = (host.Location as LocationCurve).Curve;
			XYZ xyz2 = this.DistinguishObstacle(host, curve, ptPick, startPt, endPt, ref list);
			XYZ xyz3 = XYZ.Zero;
			XYZ xyz4 = XYZ.Zero;
			if (WallAssistFunc.GetWallCurveType(host) == WallCurveType.eLineWall)
			{
				Line line = WallAssistFunc.GetWallCurve(host) as Line;
				XYZ xyz5 = Geometry.CalculateFootPoint(line, ptPick);
				xyz3 = (ptPick - xyz5).Normalize();
				XYZ xyz6 = Geometry.CalculateFootPoint(line, xyz2);
				xyz4 = (xyz6 - xyz5).Normalize();
				xyz = xyz6 - xyz4 * AssistFunc.mmToFeet(dButtWidth + num / 2.0);
			}
			else if (WallAssistFunc.GetWallCurveType(host) == WallCurveType.eArcWall)
			{
				Arc arc = WallAssistFunc.GetWallCurve(host) as Arc;
				XYZ xyz7 = Geometry.CalculateFootPoint(arc, ptPick);
				double val = (xyz2 - arc.Center).AngleOnPlaneTo(ptPick - arc.Center, XYZ.BasisZ);
				XYZ axis = -XYZ.BasisZ;
				double num2 = AssistFunc.mmToFeet(dButtWidth + num / 2.0) / arc.Radius;
				if (Geometry.LessThan(Math.PI*.5, val))
				{
					num2 = -num2;
					axis = XYZ.BasisZ;
				}
				xyz = RevitVersionFuncs.CreateRotationAtPoint(XYZ.BasisZ, num2, arc.Center).OfPoint(xyz2);
				XYZ vt = xyz3 = (xyz - arc.Center).Normalize();
				double val2 = ptPick.DistanceTo(arc.Center);
				double val3 = xyz7.DistanceTo(arc.Center);
				if (Geometry.LessThan(val2, val3))
				{
					xyz3 = -xyz3;
				}
				xyz4 = Geometry.RotateTo(vt, Math.PI*.5, axis);
			}
			XYZ xyz8 = new XYZ(xyz.X, xyz.Y, AssistFunc.GetCurrentViewLevel(this.m_doc).Elevation + AssistFunc.mmToFeet(height));
			ptNew = xyz8;
			UnifiedModified.ActivateFamilySymbol(doorType);
			FamilyInstance familyInstance = this.m_doc.Create.NewFamilyInstance(xyz8, doorType, host, AssistFunc.GetCurrentViewLevel(this.m_doc), (Autodesk.Revit.DB.Structure.StructuralType)0);
			this.m_doc.Regenerate();
			Element element = familyInstance;
			FilteredElementCollector filteredElementCollector = new FilteredElementCollector(this.m_doc);
			ElementIntersectsElementFilter elementIntersectsElementFilter = new ElementIntersectsElementFilter(element, false);
			filteredElementCollector.WherePasses(elementIntersectsElementFilter);
			filteredElementCollector.Excluding(new List<ElementId>
			{
				element.Id
			});
			try
			{
				foreach (Element element2 in filteredElementCollector)
				{
					if (!(element2.Id == host.Id))
					{
						if (element2 is Wall)
						{
							Curve curve2 = (familyInstance.Host.Location as LocationCurve).Curve;
							Curve curve3 = (element2.Location as LocationCurve).Curve;
							if (new YJKCurve(curve2).IntersectionAllPoint(curve3).Count == 0)
							{
								continue;
							}
						}
						if (element2.Category.Id.IntegerValue == -2000100 || element2.Category.Id.IntegerValue == -2000023 || element2.Category.Id.IntegerValue == -2000014 || element2.Category.Id.IntegerValue == -2000011)
						{
							YJKMessageBox.Show("与已有对象重叠,无法布置！", MessageBoxButtons.OK);
							this.m_doc.Delete(element.Id);
							break;
						}
					}
				}
			}
			catch (Exception)
			{
				familyInstance = null;
			}
			return familyInstance;
		}

		private XYZ DistinguishObstacle(Wall host, Curve cv, XYZ ptPick, XYZ ptStart, XYZ ptEnd, ref List<XYZ> arPts)
		{
			XYZ vt = (ptStart - ptEnd).Normalize();
			Level currentViewLevel = AssistFunc.GetCurrentViewLevel(this.m_doc);
			currentViewLevel.get_Parameter(BuiltInParameter.ID_PARAM).AsElementId();
			arPts.Add(ptStart);
			arPts.Add(ptEnd);
			IList<FamilyInstance> wallAssoDoorWins = WallAssistFunc.GetWallAssoDoorWins(this.m_doc, host, BuiltInCategory.OST_Doors, currentViewLevel);
			if (wallAssoDoorWins != null)
			{
				for (int i = 0; i < wallAssoDoorWins.Count; i++)
				{
					FamilyInstance instance = wallAssoDoorWins.ElementAt(i);
					arPts.Add(DoorWinAssistFunc.GetBoundPt(instance, host, 0));
					arPts.Add(DoorWinAssistFunc.GetBoundPt(instance, host, 1));
				}
			}
			IList<FamilyInstance> wallAssoDoorWins2 = WallAssistFunc.GetWallAssoDoorWins(this.m_doc, host, BuiltInCategory.OST_Windows, currentViewLevel);
			if (wallAssoDoorWins2 != null)
			{
				for (int j = 0; j < wallAssoDoorWins2.Count; j++)
				{
					FamilyInstance instance2 = wallAssoDoorWins2.ElementAt(j);
					arPts.Add(DoorWinAssistFunc.GetBoundPt(instance2, host, 0));
					arPts.Add(DoorWinAssistFunc.GetBoundPt(instance2, host, 1));
				}
			}
			ElementCategoryFilter elementCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
			IEnumerable<Element> enumerable = new FilteredElementCollector(this.m_doc, this.m_doc.ActiveView.Id).WherePasses(elementCategoryFilter).WhereElementIsNotElementType().ToElements();
			YJKCurve YJKCurve = new YJKCurve(cv);
			foreach (Element element in enumerable)
			{
				if (element.Id != host.Id)
				{
					Wall wall = RevitVersionFuncs.GetElement(this.m_doc, element.Id) as Wall;
					Curve curve = (wall.Location as LocationCurve).Curve;
					List<XYZ> list = YJKCurve.IntersectionAllPoint(curve);
					if (wall != null && list.Count != 0)
					{
						foreach (XYZ item in ElementAssistFunc.Intersect(wall, host))
						{
							arPts.Add(item);
						}
					}
				}
			}
			this.SolveColumn(host, ptPick, vt, ref arPts);
			XYZ result = XYZ.Zero;
			XYZ xyz = XYZ.Zero;
			double num = 10000000.0;
			foreach (XYZ point in arPts)
			{
				if (cv is Arc)
				{
					xyz = Geometry.CalculateFootPoint(cv as Arc, point);
				}
				else
				{
					xyz = Geometry.CalculateFootPoint(cv as Line, point);
				}
				double length = (ptPick - xyz).GetLength();
				if (length < num)
				{
					num = length;
					result = xyz;
				}
			}
			return result;
		}

		private void GetCorrectInsertRange(Wall wall, Curve cv, XYZ ptPick, ref XYZ ptStart, ref XYZ ptEnd)
		{
			if (cv is Arc)
			{
				Arc arc = cv as Arc;
				ptPick = Geometry.CalculateFootPoint(arc, ptPick);
				List<XYZ> arPts = new List<XYZ>();
				XYZ xyz = this.DistinguishObstacle(wall, cv, ptPick, ptStart, ptEnd, ref arPts);
				xyz = Geometry.CalculateFootPoint(arc, xyz);
				if (xyz.IsAlmostEqualTo(ptStart, 0.1))
				{
					ptEnd = this.GetEndPoint(arc, ptStart, ptPick, arPts, false, null);
					return;
				}
				if (xyz.IsAlmostEqualTo(ptEnd, 0.1))
				{
					ptStart = this.GetEndPoint(arc, ptEnd, ptPick, arPts, true, null);
					return;
				}
				Arc arc2 = Arc.Create(ptStart, xyz, this.GetArcMid(ptStart, xyz, arc));
				if (this.IsPointOnCurve(arc2, ptPick))
				{
					Arc arcTemp = Arc.Create(xyz, ptEnd, this.GetArcMid(xyz, ptEnd, arc));
					ptEnd = xyz;
					ptStart = this.GetEndPoint(arc, ptEnd, ptPick, arPts, true, arcTemp);
					return;
				}
				ptStart = xyz;
				ptEnd = this.GetEndPoint(arc, ptStart, ptPick, arPts, false, arc2);
				return;
			}
			else
			{
				Line line = cv as Line;
				ptPick = Geometry.CalculateFootPoint(line, ptPick);
				List<XYZ> arPts2 = new List<XYZ>();
				XYZ xyz2 = this.DistinguishObstacle(wall, cv, ptPick, ptStart, ptEnd, ref arPts2);
				xyz2 = Geometry.CalculateFootPoint(line, xyz2);
				if (xyz2.IsAlmostEqualTo(ptStart))
				{
					ptEnd = this.GetEndPoint(line, ptStart, ptPick, arPts2);
					return;
				}
				if (xyz2.IsAlmostEqualTo(ptEnd))
				{
					ptStart = this.GetEndPoint(line, ptEnd, ptPick, arPts2);
					return;
				}
				Line cv2 = Line.CreateBound(ptStart, xyz2);
				if (this.IsPointOnCurve(cv2, ptPick))
				{
					ptEnd = xyz2;
					ptStart = this.GetEndPoint(line, ptEnd, ptPick, arPts2);
					return;
				}
				ptStart = xyz2;
				ptEnd = this.GetEndPoint(line, ptStart, ptPick, arPts2);
				return;
			}
		}

		private XYZ GetEndPoint(Line cv, XYZ pt, XYZ ptPick, IList<XYZ> arPts)
		{
			double num = 10000000.0;
			XYZ result = XYZ.Zero;
			foreach (XYZ point in arPts)
			{
				XYZ xyz = Geometry.CalculateFootPoint(cv, point);
				if (!xyz.IsAlmostEqualTo(pt))
				{
					Line cv2 = Line.CreateBound(pt, xyz);
					if (this.IsPointOnCurve(cv2, ptPick))
					{
						double length = (pt - xyz).GetLength();
						if (length < num)
						{
							num = length;
							result = xyz;
						}
					}
				}
			}
			return result;
		}

		private XYZ GetEndPoint(Arc cv, XYZ pt, XYZ ptPick, IList<XYZ> arPts, bool isStart, Arc arcTemp = null)
		{
			double num = 10000000.0;
			XYZ result = XYZ.Zero;
			foreach (XYZ point in arPts)
			{
				XYZ xyz = Geometry.CalculateFootPoint(cv, point);
				if ((!(arcTemp != null) || !this.IsPointOnCurve(arcTemp, xyz)) && !xyz.IsAlmostEqualTo(pt))
				{
					Arc cv2;
					if (isStart)
					{
						cv2 = Arc.Create(xyz, pt, this.GetArcMid(xyz, pt, cv));
					}
					else
					{
						cv2 = Arc.Create(xyz, pt, this.GetArcMid(pt, xyz, cv));
					}
					if (this.IsPointOnCurve(cv2, ptPick))
					{
						double length = (pt - xyz).GetLength();
						if (length < num)
						{
							num = length;
							result = xyz;
						}
					}
				}
			}
			return result;
		}

		public XYZ GetArcMid(XYZ ptEnd1, XYZ ptEnd2, Arc arc)
		{
			XYZ center = arc.Center;
			XYZ xyz = ptEnd1.Subtract(center);
			XYZ xyz2 = ptEnd2.Subtract(center);
			double num = xyz.AngleOnPlaneTo(xyz2, arc.Normal);
			XYZ xyz3 = Transform.CreateRotationAtPoint(arc.Normal, num * 0.5, center).OfVector(xyz);
			return center.Add(xyz3);
		}

		private bool IsPointOnCurve(Curve cv, XYZ pt)
		{
			return cv.Project(pt).XYZPoint.IsAlmostEqualTo(pt);
		}

		private void EqualWallInsert()
		{
			this.m_delModifyInstance = new InsertDoorAndWindowManage.DelModifyInstance(this.RedrawInstanceEqualWall);
		}

		private void RedrawInstanceEqualWall()
		{
			this.m_bIsAgain = false;
			Wall wall = null;
			XYZ zero = XYZ.Zero;
			XYZ zero2 = XYZ.Zero;
			XYZ zero3 = XYZ.Zero;
			FamilyInstance instance = this.m_elem as FamilyInstance;
			this.GetFamilyInstenceData(instance, ref wall, ref zero, ref zero2, ref zero3);
			XYZ startPt = WallAssistFunc.GetStartPt(wall);
			XYZ endPt = WallAssistFunc.GetEndPt(wall);
			Transaction transaction = new Transaction(this.m_doc, "StartModifyInstance");
			try
			{
				transaction.Start();
				this.m_doc.Delete(this.m_elem.Id);
				Curve curve = (wall.Location as LocationCurve).Curve;
				this.GetCorrectInsertRange(wall, curve, zero3, ref startPt, ref endPt);
				transaction.Commit();
				double num = this.m_doorData.Symbol.get_Parameter(BuiltInParameter.CASEWORK_WIDTH).AsDouble();
				double height = double.Parse(this.m_doorData.DoorAndWinBottomHigh);
				this.m_strEqualWall = this.m_jig.inputForm.GetInputValue();
				if (this.m_strEqualWall == "" || this.m_strEqualWall == null)
				{
					YJKMessageBox.Show("请输入等分个数");
				}
				else
				{
					int num2 = int.Parse(this.m_strEqualWall);
					if (num2 == 0 || num2 < 0)
					{
						YJKMessageBox.Show("请输入正确的等分个数");
					}
					else
					{
						double num3 = 0.0;
						List<XYZ> wallEqualPoints = this.GetWallEqualPoints(curve, startPt, endPt, num, num2, height, ref num3);
						if (Geometry.LessThan(num3 - num / 2.0, 0.04))
						{
							this.m_bIsAgain = true;
						}
						else
						{
							transaction.Start();
							string text = "";
							List<Element> list = this.EqualSingleInsert(wallEqualPoints, this.m_doorData.Symbol, wall, height, ref text, zero, zero2, zero3);
							transaction.Commit();
							if (list[0].IsValidObject)
							{
								this.SetInsertDirection(list);
							}
						}
					}
				}
			}
			catch (Exception)
			{
				transaction.RollBack();
			}
		}

		private List<Element> EqualSingleInsert(List<XYZ> arPts, FamilySymbol doorType, Wall host, double height, ref string message, XYZ isSelPositiveSideline, XYZ nearbyStart, XYZ ptInsert)
		{
			List<Element> list = new List<Element>();
			foreach (XYZ pt in arPts)
			{
				Element element = this.DoInsertNew(pt, doorType, host, height, ref message, isSelPositiveSideline, nearbyStart, ptInsert);
				if (element != null)
				{
					list.Add(element);
				}
			}
			return list;
		}

		private Element DoInsertNew(XYZ pt, FamilySymbol type, Wall host, double height, ref string message, XYZ isSelPositiveSideline, XYZ nearbyStart, XYZ ptInsert)
		{
			FamilyInstance familyInstance = null;
			if (this.GetCurrentLevelId(ref message) == null)
			{
				return null;
			}
			XYZ xyz = new XYZ(pt.X, pt.Y, AssistFunc.GetCurrentViewLevel(this.m_uiDoc.Document).Elevation + AssistFunc.mmToFeet(height));
			try
			{
				if (!type.IsActive)
				{
					type.Activate();
					this.m_doc.Regenerate();
				}
				familyInstance = this.m_doc.Create.NewFamilyInstance(xyz, type, host, AssistFunc.GetCurrentViewLevel(this.m_uiDoc.Document), (Autodesk.Revit.DB.Structure.StructuralType)0);
				this.SetParameter(familyInstance);
				this.m_doc.Regenerate();
				familyInstance.flipFacing();
				familyInstance.flipFacing();
				Curve curve = (host.Location as LocationCurve).Curve;
				if (familyInstance.CanFlipFacing)
				{
					if (curve is Arc)
					{
						Arc arc = curve as Arc;
						XYZ pt2 = (arc.Center - ptInsert).Normalize();
						XYZ pt3 = (arc.Center - new XYZ(xyz.X, xyz.Y, arc.Center.Z)).Normalize();
						if (!this.IsFlip(pt2, isSelPositiveSideline, pt3, familyInstance.FacingOrientation))
						{
							familyInstance.flipFacing();
						}
					}
					else if (!familyInstance.FacingOrientation.IsAlmostEqualTo(isSelPositiveSideline))
					{
						familyInstance.flipFacing();
					}
				}
				if (familyInstance.CanFlipHand)
				{
					if (curve is Arc)
					{
						XYZ xyz2 = isSelPositiveSideline.CrossProduct(nearbyStart).Normalize();
						XYZ xyz3 = familyInstance.FacingOrientation.CrossProduct(familyInstance.HandOrientation).Normalize();
						if (!xyz2.IsAlmostEqualTo(xyz3))
						{
							familyInstance.flipHand();
						}
					}
					else if (!familyInstance.HandOrientation.IsAlmostEqualTo(nearbyStart))
					{
						familyInstance.flipHand();
					}
				}
			}
			catch (Exception)
			{
			}
			return familyInstance;
		}

		private bool IsFlip(XYZ pt1, XYZ pt2, XYZ pt3, XYZ pt4)
		{
			int num;
			if (pt1.IsAlmostEqualTo(pt2))
			{
				num = 1;
			}
			else
			{
				num = 0;
			}
			int num2;
			if (pt3.IsAlmostEqualTo(pt4))
			{
				num2 = 1;
			}
			else
			{
				num2 = 0;
			}
			return num == num2;
		}

		public ElementId GetCurrentLevelId(ref string message)
		{
			Level currentViewLevel = AssistFunc.GetCurrentViewLevel(this.m_doc);
			if (currentViewLevel == null)
			{
				message = "当前激活的View不是平面的View！";
				return null;
			}
			return currentViewLevel.get_Parameter(BuiltInParameter.ID_PARAM).AsElementId();
		}

		private void SetInsertDirection(List<Element> elems)
		{
			if (this.m_bIsAddTag && this.GetTagSymbolNew())
			{
				foreach (Element element in elems)
				{
					FamilyInstance familyInstance = (FamilyInstance)element;
					this.DoInsertTag(familyInstance);
				}
			}
		}

		private List<XYZ> GetWallEqualPoints(Curve curve, XYZ pt1, XYZ pt2, double dDoorWidth, int count, double height, ref double dTotal)
		{
			List<XYZ> list = null;
			int num = count + 1;
			if (curve as Line != null)
			{
				double num2 = pt1.DistanceTo(pt2) + dDoorWidth;
				XYZ xyz = (pt2 - pt1).Normalize();
				double num3 = num2 / (double)num;
				list = new List<XYZ>();
				for (int i = 1; i < num; i++)
				{
					XYZ item = pt1 + xyz * (num3 * (double)i - dDoorWidth / 2.0);
					list.Add(item);
				}
				dTotal = list[0].DistanceTo(pt1);
			}
			Arc arc = curve as Arc;
			if (arc != null)
			{
				arc = Arc.Create(pt1, pt2, this.GetArcMid(pt1, pt2, arc));
				XYZ center = arc.Center;
				double hyendParameter = arc.GetYJKEndParameter(0);
				double hyendParameter2 = arc.GetYJKEndParameter(1);
				double num4 = dDoorWidth / arc.Radius;
				double num5 = (hyendParameter2 - hyendParameter + num4) / (double)num;
				XYZ normal = arc.Normal;
				Transform transform = RevitVersionFuncs.CreateRotationAtPoint(normal, num5 - num4 / 2.0, center);
				list = new List<XYZ>();
				XYZ xyz2 = transform.OfPoint(pt1);
				list.Add(xyz2);
				Transform transform2 = RevitVersionFuncs.CreateRotationAtPoint(normal, num5, center);
				for (int j = 1; j < count; j++)
				{
					xyz2 = transform2.OfPoint(xyz2);
					XYZ item2 = new XYZ(xyz2.X, xyz2.Y, AssistFunc.mmToFeet(height));
					list.Add(item2);
				}
				dTotal = list[0].DistanceTo(pt1);
			}
			return list;
		}

		private void SolveColumn(Wall wall, XYZ ptPick, XYZ vt, ref List<XYZ> arPts)
		{
			List<Element> wallsJoinedElement = this.GetWallsJoinedElement(wall);
			List<Element> wallsIntersectElement = this.GetWallsIntersectElement(wall);
			List<Element> list = new List<Element>();
			list.AddRange(wallsJoinedElement);
			list.AddRange(wallsIntersectElement);
			Curve curve = (wall.Location as LocationCurve).Curve;
			foreach (Element column in list)
			{
				this.GetColumnUpperSurface(column, curve, ptPick, ref arPts);
			}
		}

		private void GetColumnUpperSurface(Element column, Curve cv, XYZ ptPick, ref List<XYZ> arPts)
		{
			Face face = null;
			XYZ basisZ = XYZ.BasisZ;
			foreach (Solid solid in new ColumnProfileAnalyzer(this.m_cmdData).GetElementSolids(column))
			{
				if (solid == null)
				{
					break;
				}
				foreach (object obj in solid.Faces)
				{
					if (obj is PlanarFace)
					{
						PlanarFace planarFace = obj as PlanarFace;
						if (planarFace.FaceNormal.IsAlmostEqualTo(basisZ))
						{
							face = planarFace;
							break;
						}
					}
				}
				XYZ endPoint = this.GetEndPoint(face, cv, ptPick);
				arPts.Add(endPoint);
			}
		}

		private XYZ GetEndPoint(Face face, Curve WallCv, XYZ ptPick)
		{
			XYZ result = XYZ.Zero;
			double val = 10000000.0;
			XYZ endPoint = WallCv.GetEndPoint(0);
			foreach (object obj in face.EdgeLoops)
			{
				foreach (object obj2 in ((EdgeArray)obj))
				{
					Curve curve = ((Edge)obj2).AsCurve();
					XYZ xyz = curve.GetEndPoint(0);
					XYZ xyz2 = curve.GetEndPoint(1);
					Curve curve2;
					if (curve is Line)
					{
						xyz = new XYZ(xyz.X, xyz.Y, endPoint.Z);
						xyz2 = new XYZ(xyz2.X, xyz2.Y, endPoint.Z);
						curve2 = Line.CreateBound(xyz, xyz2);
					}
					else
					{
						Arc arc = curve as Arc;
						XYZ xyz3 = this.GetArcMid(xyz, xyz2, arc);
						xyz = new XYZ(xyz.X, xyz.Y, endPoint.Z);
						xyz2 = new XYZ(xyz2.X, xyz2.Y, endPoint.Z);
						xyz3 = new XYZ(xyz3.X, xyz3.Y, endPoint.Z);
						curve2 = Arc.Create(xyz, xyz2, xyz3);
					}
					foreach (XYZ xyz4 in new YJKCurve(curve2).IntersectionAllPoint(WallCv))
					{
						double num = xyz4.DistanceTo(ptPick);
						if (Geometry.LessThan(num, val))
						{
							result = xyz4;
							val = num;
						}
					}
				}
			}
			return result;
		}

		private List<Element> GetWallsJoinedElement(Element wall)
		{
			List<Element> list = new List<Element>();
			foreach (ElementId elementId in JoinGeometryUtils.GetJoinedElements(this.m_doc, wall))
			{
				Element element = this.m_doc.GetElement(elementId);
				if (element is FamilyInstance)
				{
					FamilyInstance familyInstance = element as FamilyInstance;
					if (familyInstance.Category.Id.IntegerValue == -2000100 || familyInstance.Category.Id.IntegerValue == -2001330)
					{
						list.Add(familyInstance);
					}
				}
			}
			return list;
		}

		private List<Element> GetWallsIntersectElement(Element wall)
		{
			FilteredElementCollector filteredElementCollector = new FilteredElementCollector(this.m_doc);
			filteredElementCollector.OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_Columns);
			FilteredElementCollector filteredElementCollector2 = new FilteredElementCollector(this.m_doc);
			filteredElementCollector2.OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_StructuralColumns);
			ElementIntersectsElementFilter elementIntersectsElementFilter = new ElementIntersectsElementFilter(wall);
			filteredElementCollector.WherePasses(elementIntersectsElementFilter);
			filteredElementCollector2.WherePasses(elementIntersectsElementFilter);
			List<Element> list = new List<Element>();
			foreach (Element item in filteredElementCollector)
			{
				list.Add(item);
			}
			foreach (Element item2 in filteredElementCollector2)
			{
				list.Add(item2);
			}
			return list;
		}

		private bool GetTagSymbol()
		{
			bool result;
			try
			{
				List<DbCategory> all = FamilyLibDatabase.GetSqliteDB(SubjectType.System, this.m_uiApp.Application.VersionNumber).CategoryTable.GetAll();
				if ((int)this.m_category == -2000023)
				{
					using (List<DbCategory>.Enumerator enumerator = all.GetEnumerator())
					{
						while (enumerator.MoveNext())
						{
							DbCategory dbCategory = enumerator.Current;
							if (dbCategory.Name == "门标记")
							{
								List<FamilySymbol> symbols = dbCategory.GetAllFamilies(false, CheckType.All).FirstOrDefault<DbFamily>().Reload(this.m_uiApp.ActiveUIDocument.Document).GetSymbols();
								if (symbols.Count > 0)
								{
									this.m_TagSymbol = symbols[0];
								}
							}
						}
						goto IL_12B;
					}
				}
				foreach (DbCategory dbCategory2 in all)
				{
					if (dbCategory2.Name == "窗标记")
					{
						List<FamilySymbol> symbols2 = dbCategory2.GetAllFamilies(false, CheckType.All).FirstOrDefault<DbFamily>().Reload(this.m_uiApp.ActiveUIDocument.Document).GetSymbols();
						if (symbols2.Count > 0)
						{
							this.m_TagSymbol = symbols2[0];
						}
					}
				}
				IL_12B:
				result = true;
			}
			catch (Exception)
			{
				YJKMessageBox.Show("获取标记失败");
				result = false;
			}
			return result;
		}

		private bool GetTagSymbolNew()
		{
			string appRootPath = AssistFunc.GetAppRootPath();
			string versionNumber = this.m_App.VersionNumber;
			string text = appRootPath + "\\FamilyLib\\Family\\";
			text += versionNumber;
			text += "\\DoorAndWinTag\\";
			Family family = null;
			Transaction transaction = new Transaction(this.m_doc);
			bool result;
			try
			{
				string text2 = string.Empty;
				if ((int)this.m_category == -2000023)
				{
					text2 = "门标记";
				}
				else
				{
					text2 = "窗标记";
				}
				string text3 = Path.Combine(text, text2 + ".rfa");
				transaction.Start("load families");
				family = ElementFiltering.FindFamily(this.m_doc, text2);
				if (family == null)
				{
                    this.m_doc.LoadFamily(text3, out family);
				}
				this.m_TagSymbol = family.GetSymbols().FirstOrDefault<FamilySymbol>();
				transaction.Commit();
				result = true;
			}
			catch (Exception)
			{
				if (transaction.IsValidObject && transaction.HasStarted())
				{
					transaction.RollBack();
				}
				YJKMessageBox.Show("获取标记失败");
				result = false;
			}
			return result;
		}

		private ExternalCommandData m_cmdData;

		private Document m_doc;

		private UIApplication m_uiApp;

		private UIDocument m_uiDoc;

		private Autodesk.Revit.ApplicationServices.Application m_App;

		private BuiltInCategory m_category;

		public static ElementId g_NewSymbolId = ElementId.InvalidElementId;

		public static ElementId g_OverlapElemId = ElementId.InvalidElementId;

		private FamilySymbol m_TagSymbol;

		private List<ElementId> m_lstInstanceOlds;

		private InsertMode m_insertMode;

		private DoorData m_doorData = new DoorData();

		private bool m_bIsAddTag;

		private XInputDialog m_jig;

		private string m_strPlieWidth;

		private string m_strEqualWall;

		private Element m_elem;

		private InsertDoorAndWindowManage.DelModifyInstance m_delModifyInstance;

		private bool m_bIsLock = true;

		private OperationType operaType;

		private Family m_family;

		public static Dis m_dis;

		private bool m_bIsAgain;

		public delegate void DelModifyInstance();
	}
}
